home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13038 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.8 KB

  1. Path: ssds.com!usenet
  2. From: Ron Romero <ron.romero@ssds.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: If I were...
  5. Date: Fri, 22 Mar 1996 09:33:39 -0500
  6. Organization: SSDS, Inc.
  7. Distribution: inet
  8. Message-ID: <3152BA43.11D3@ssds.com>
  9. NNTP-Posting-Host: rem_vie23.ssds.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (Win16; I)
  14. CC: ron.romero@ssds.com
  15.  
  16. (I'm reposting this article as the original didn't get posted)
  17.  
  18. JS Willans wrote:
  19. >
  20. > [...]
  21. >
  22. > I am considering writing the program in pure C++, to get it running on a
  23. > text based platform, and then porting it to the windows platform using
  24. > Bordland C++ 4.0.  Is this making the task of programming for Visual C++
  25. > more difficult, or is this a wise approach?
  26.  
  27. In general, writing a program to work with multiple interfaces is a good idea.
  28. By writing your program first for a text based platform, then for MS Windows,
  29. you are forcing yourself to split the user interface of your program from the
  30. underlying implementation.  Making this seperation keeps the internals of your
  31. program from reflecting the peculiarities of the user interface.  Thus your
  32. program is more robust, can be adapted for multiple platforms, and can have
  33. cleaner code.
  34.  
  35. There are a couple of techniques for managing the user interface/ internal
  36. implementation split. You can physically divide the source code into two
  37. directories.  This makes the split very obvious and definite.  And, when you add
  38. new interfaces, you simply add new interface directories.
  39.  
  40. Also, you should try to keep the first (text based) interface working when you
  41. port the program to MS Windows.  Do not hack the internal code just to get the
  42. user interface to work.  If you do find you need to change something, either
  43. change the text interface as well, or, better yet, make the change incremental.
  44.  That is, change the internals in such a way that the old code still works.
  45.  
  46. This is an example of a common pattern in programming, called Model/View.
  47. (Technically "Model/View/Controller," but most people don't use Controllers")
  48. The Model is the "internal" code; it is not interface specific.  Your model is
  49. written in pure C++, without platform extensions.  The View is the user
  50. interface.  It provides a "view" of the model.  The view knows about the model,
  51. but the model has absolutely no knowledge of the view.  Thus, you can change out
  52. views without the model's knowledge, in your example, switching from text to
  53. windows.
  54.  
  55. > Regards
  56. >
  57. > James
  58. >
  59. > ______________________________________________________________________________
  60. > James Willans                                      Music and Computing Student
  61. > University of Keele                                email u5b34@cs.keele.ac.uk
  62. > Keele                                                    u5b34@cc.keele.ac.uk
  63. > Staffordshire
  64.  
  65. Ron Romero
  66. SSDS, Inc.
  67.